<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

</body>
<script>
  // eg1
  console.log(num);  // => undefined
  var num = 10;

  //eg2
  f1();  // => I am f1
  function f1() {
    console.log("I am f1");
  }

  //eg3
  // f2(); // => err: Uncaught TypeError: f2 is not a function
  // var f2 = function () {
  //   console.log("I am f2");
  // }

  // var n = 10;
  // f();  // => undefined
  // function f() {
  //   console.log(n);
  //   var n = 20;
  // }

  f(); // => 9 9 9
  console.log(c); // => 9
  console.log(b); // => 9
  console.log(a); // => a is not defined

  // function f(){
  //   var a = b = c = 9;
  //   console.log(a);
  //   console.log(b);
  //   console.log(c);
  // }

  function f(){
    var a;
    a = 9;
    b = 9;
    c = 9;
    console.log(a);
    console.log(b);
    console.log(c);
  }

  f();
  console.log(c);
  console.log(b);
  console.log(a);

</script>
</html>